from cpgzh import *
from setup import *


class Home:
    def __init__(self) -> None:
        "开始界面"
        self.font = Font()
        self.pen = Pen()
        bg1 = Actor(f"主场景背景")
        bg2 = Actor(f"主场景背景")
        bg1.scale = SCALE
        bg2.scale = SCALE
        bg1.left = 0
        bg2.left = bg1.right
        bg1.top = bg2.top = 0
        start = Actor("开始游戏按钮-normal-000", center=(720, 450 * SCALE))
        start.scale = 0.7 * SCALE        
        boss = Actor("黑暗巨龙", center=(780 * SCALE, 300 * SCALE))
        boss.all_images = boss.images
        boss.images = [i for i in boss.all_images if "待机" in i]
        boss.animate_fps = 10
        boss.scale = 2
        hero = Actor("王子", center=(480 * SCALE, 200 * SCALE))
        hero.images = [i for i in hero.images if "待机" in i]
        hero.scale = 1.2
        hero.animate_fps = 10
        princess = Actor("光明女神", center=(180 * SCALE, 300 * SCALE))
        princess.images = [i for i in princess.images if "待机" in i]
        princess.scale = 1.2
        princess.animate_fps = 10
        self.actors = [
            bg1,
            bg2,
            boss,
            hero,
            princess,
            start,
        ]
        self.bgs = [bg1, bg2]
        self.start = start
        self.dstart=0.01

    def update(self):
        "更新数据"        
        for bg in self.bgs:
            bg.x -= 1
            if bg.right <= 0:
                bg.left = 960

    def draw(self):
        "画图了"
        for a in self.actors:
            a.draw()
        pen = self.pen
        font = self.font
        pen.text("开始上课", center=(480 * SCALE, 450 * SCALE), font=font)
    def smaller(self):
        "变小"
        self.start.scale -= 0.05


    def startGame(self):
        "开始游戏"
        master.status = 1


    def start_game(self):
        "开始游戏的特效"
        self.start.image = "开始游戏按钮-disabled-000"
        master.create_delay_tasks(self.smaller, 0.05, 6)
        master.create_delay_tasks(self.startGame, 0.35)
    
home=Home()